﻿Public Class ClsTLedgerSettingDbAccess
    Inherits ClsBaseDbAccess

    '用户表 ： data/l_xxx.mdb库中 T_LedgerSetting表
    'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\自写系统\rjcwxt\Rjcwxt\data\l_xxx.mdb;Persist Security Info=True
    '在库中的表名 T_LedgerSetting

    Public Sub New(ByVal s As String)
        MyBase.New(s, TABLE_NAME_T_LEDGER_SETTING)
    End Sub

    Public Sub New(ByVal s As String, ByVal n As String)
        MyBase.New(s, n)
    End Sub

    Public Function InsertTLedgerSetting(ByVal tmpCls As ClsTLedgerSetting) As Int16

        Try

            Dim tmpSql As String
            Dim tmpDbAccess = GetConnection() 'New ClsDbAccessMdb(mConnectionString)

            Dim tmpParas(35) As OleDb.OleDbParameter
            Dim tmpReturn As Integer

            '打开数据库
            tmpDbAccess.DbOpen()
            '构造插入查询语句
            tmpSql = "Insert Into [" & TABLE_NAME_T_LEDGER_SETTING & "] "
            tmpSql &= "([CompanyName],[IndustryTypeId],[IndustryType],[LedgerIfOpened],[LedgerOPendDate],"
            tmpSql &= "[LedgerWorkYear],[LedgerOpenedWorkYear],[LedgerSubAcctLength],[LedgerOwnerCurrency],[CashCode],"
            tmpSql &= "[BankCode],[AssetsCode],[DepCode],[ReceiveCode],[PayCode],[GainCode],[DevCode],[StockCode],"
            tmpSql &= "[IncAndDecCode],[IfPrintQuantity],[IfPrintForeignMoney],[IfPrintBankInfo],[IfPrintNegative],"
            tmpSql &= "[IfPrintManager],[IfPrintPoster],[IfPrintChecker],[IfPrintCasher],[IfPrintMaker],[IfPrintPerson],"
            tmpSql &= "[IfPrintDate],[IfSelfPostVoucher],[IfSelfCheckVoucher],[LedgerAbSetup],[LedgerId],"
            tmpSql &= "[RelativeLedgerId],[LedgerOneLevelLength])"
            tmpSql &= " values "
            tmpSql &= "(@CompanyName,@IndustryTypeId,@IndustryType,@LedgerIfOpened,@LedgerOPendDate,"
            tmpSql &="@LedgerWorkYear,@LedgerOpenedWorkYear,@LedgerSubAcctLength,@LedgerOwnerCurrency,"
            tmpSql &= "@CashCode,@BankCode,@AssetsCode,@DepCode,@ReceiveCode,@PayCode,@GainCode,@DevCode,"
            tmpSql &="@StockCode,@IncAndDecCode,@IfPrintQuantity,@IfPrintForeignMoney,@IfPrintBankInfo,"
            tmpSql &= "@IfPrintNegative,@IfPrintManager,@IfPrintPoster,@IfPrintChecker,@IfPrintCasher,"
            tmpSql &="@IfPrintMaker,@IfPrintPerson,@IfPrintDate,@IfSelfPostVoucher,@IfSelfCheckVoucher,"
            tmpSql &= "@LedgerAbSetup,@LedgerId,@RelativeLedgerId,@LedgerOneLevelLength)"
            '构造查询语句
            'tmpSql = "insert into [" & TABLE_NAME_T_LEDGER_SETTING & "] ("
            'tmpSql &= "[CompanyName],[IndustryTypeId],[IndustryType],[LedgerIfOpened],[LedgerOPendDate],"
            'tmpSql &= "[LedgerWorkYear],[LedgerOpenedWorkYear],[LedgerSubAcctLength],[LedgerOwnerCurrency],[CashCode],"
            'tmpSql &= "[BankCode],[AssetsCode],[DepCode],[ReceiveCode],[PayCode],[GainCode],[DevCode],[StockCode],"
            'tmpSql &= "[IncAndDecCode],[IfPrintQuantity],[IfPrintForeignMoney],[IfPrintBankInfo],[IfPrintNegative],"
            'tmpSql &= "[IfPrintManager],[IfPrintPoster],[IfPrintChecker],[IfPrintCasher],[IfPrintMaker],[IfPrintPerson],"
            'tmpSql &= "[IfPrintDate],[IfSelfPostVoucher],[IfSelfCheckVoucher],[LedgerAbSetup],[LedgerId],[RelativeLedgerId],[LedgerOneLevelLength])"
            'tmpSql &= " values("
            'tmpSql &= "@CompanyName,@IndustryTypeId,@IndustryType,@LedgerIfOpened,@LedgerOPendDate,"
            'tmpSql &= "@LedgerWorkYear,@LedgerOpenedWorkYear,@LedgerSubAcctLength,@LedgerOwnerCurrency,@CashCode,"
            'tmpSql &= "@BankCode,@AssetsCode,@DepCode,@ReceiveCode,@PayCode,@GainCode,@DevCode,@StockCode,"
            'tmpSql &= "@IncAndDecCode,@IfPrintQuantity,@IfPrintForeignMoney,@IfPrintBankInfo,@IfPrintNegative,"
            'tmpSql &= "@IfPrintManager,@IfPrintPoster,@IfPrintChecker,@IfPrintCasher,@IfPrintMaker,@IfPrintPerson,"
            'tmpSql &= "@IfPrintDate,@IfSelfPostVoucher,@IfSelfCheckVoucher,@LedgerAbSetup,@LedgerId,@RelativeLedgerId,@LedgerOneLevelLength"
            'tmpSql &= ")"


            '构造参数集合
            'tmpParas(0) = New OleDb.OleDbParameter("@LedgerSettingId", OleDb.OleDbType.Integer)
            'tmpParas(0) = New OleDb.OleDbParameter("@CompanyName", OleDb.OleDbType.VarWChar)
            'tmpParas(1) = New OleDb.OleDbParameter("@IndustryTypeId", OleDb.OleDbType.Integer)
            'tmpParas(2) = New OleDb.OleDbParameter("@IndustryType", OleDb.OleDbType.VarWChar)
            'tmpParas(3) = New OleDb.OleDbParameter("@LedgerIfOpened", OleDb.OleDbType.Boolean)
            'tmpParas(4) = New OleDb.OleDbParameter("@LedgerOpenedDate", OleDb.OleDbType.DBTimeStamp)
            'tmpParas(5) = New OleDb.OleDbParameter("@LedgerWorkYear", OleDb.OleDbType.VarWChar)
            'tmpParas(6) = New OleDb.OleDbParameter("@LedgerOpenWorkYear", OleDb.OleDbType.VarWChar)
            'tmpParas(7) = New OleDb.OleDbParameter("@LedgerSubAcctLength", OleDb.OleDbType.Integer)
            'tmpParas(8) = New OleDb.OleDbParameter("@LedgerOwnerCurrency", OleDb.OleDbType.VarWChar)
            'tmpParas(9) = New OleDb.OleDbParameter("@CashCode", OleDb.OleDbType.VarWChar)
            'tmpParas(10) = New OleDb.OleDbParameter("@BankCode", OleDb.OleDbType.VarWChar)
            'tmpParas(11) = New OleDb.OleDbParameter("@AssetsCode", OleDb.OleDbType.VarWChar)
            'tmpParas(12) = New OleDb.OleDbParameter("@DepCode", OleDb.OleDbType.VarWChar)
            'tmpParas(13) = New OleDb.OleDbParameter("@ReceiveCode", OleDb.OleDbType.VarWChar)
            'tmpParas(14) = New OleDb.OleDbParameter("@PayCode", OleDb.OleDbType.VarWChar)
            'tmpParas(15) = New OleDb.OleDbParameter("@GainCode", OleDb.OleDbType.VarWChar)
            'tmpParas(16) = New OleDb.OleDbParameter("@DevCode", OleDb.OleDbType.VarWChar)
            'tmpParas(17) = New OleDb.OleDbParameter("@StockCode", OleDb.OleDbType.VarWChar)
            'tmpParas(18) = New OleDb.OleDbParameter("@IncAndDecCode", OleDb.OleDbType.VarWChar)
            'tmpParas(19) = New OleDb.OleDbParameter("@IfPrintQuantity", OleDb.OleDbType.Boolean)
            'tmpParas(20) = New OleDb.OleDbParameter("@IfPrintForeignMoney", OleDb.OleDbType.Boolean)
            'tmpParas(21) = New OleDb.OleDbParameter("@IfPrintBankInfo", OleDb.OleDbType.Boolean)
            'tmpParas(22) = New OleDb.OleDbParameter("@IfPrintNegative", OleDb.OleDbType.Boolean)
            'tmpParas(23) = New OleDb.OleDbParameter("@IfPrintManager", OleDb.OleDbType.Boolean)
            'tmpParas(24) = New OleDb.OleDbParameter("@IfPrintPoster", OleDb.OleDbType.Boolean)
            'tmpParas(25) = New OleDb.OleDbParameter("@IfPrintChecker", OleDb.OleDbType.Boolean)
            'tmpParas(26) = New OleDb.OleDbParameter("@IfPrintCasher", OleDb.OleDbType.Boolean)
            'tmpParas(27) = New OleDb.OleDbParameter("@IfPrintMaker", OleDb.OleDbType.Boolean)
            'tmpParas(28) = New OleDb.OleDbParameter("@IfPrintPerson", OleDb.OleDbType.Boolean)
            'tmpParas(29) = New OleDb.OleDbParameter("@IfPrintDate", OleDb.OleDbType.Boolean)
            'tmpParas(30) = New OleDb.OleDbParameter("@IfSelfPostVoucher", OleDb.OleDbType.Boolean)
            'tmpParas(31) = New OleDb.OleDbParameter("@IfSelfCheckVoucher", OleDb.OleDbType.Boolean)
            'tmpParas(32) = New OleDb.OleDbParameter("@LedgerAbSetup", OleDb.OleDbType.Integer)
            'tmpParas(33) = New OleDb.OleDbParameter("@LedgerId", OleDb.OleDbType.Integer)
            'tmpParas(34) = New OleDb.OleDbParameter("@RelativeLedgerId", OleDb.OleDbType.Integer)
            'tmpParas(35) = New OleDb.OleDbParameter("@LedgerOneLevelLength", OleDb.OleDbType.SmallInt)
            tmpParas(0) = New OleDb.OleDbParameter("@CompanyName", OleDb.OleDbType.VarWChar)
            tmpParas(1) = New OleDb.OleDbParameter("@IndustryTypeId", OleDb.OleDbType.Integer)
            tmpParas(2) = New OleDb.OleDbParameter("@IndustryType", OleDb.OleDbType.VarWChar)
            tmpParas(3) = New OleDb.OleDbParameter("@LedgerIfOpened", OleDb.OleDbType.Boolean)
            tmpParas(4) = New OleDb.OleDbParameter("@LedgerOpenedDate", OleDb.OleDbType.DBDate)
            tmpParas(5) = New OleDb.OleDbParameter("@LedgerWorkYear", OleDb.OleDbType.VarWChar)
            tmpParas(6) = New OleDb.OleDbParameter("@LedgerOpenWorkYear", OleDb.OleDbType.VarWChar)
            tmpParas(7) = New OleDb.OleDbParameter("@LedgerSubAcctLength", OleDb.OleDbType.Integer)
            tmpParas(8) = New OleDb.OleDbParameter("@LedgerOwnerCurrency", OleDb.OleDbType.VarWChar)
            tmpParas(9) = New OleDb.OleDbParameter("@CashCode", OleDb.OleDbType.VarWChar)
            tmpParas(10) = New OleDb.OleDbParameter("@BankCode", OleDb.OleDbType.VarWChar)
            tmpParas(11) = New OleDb.OleDbParameter("@AssetsCode", OleDb.OleDbType.VarWChar)
            tmpParas(12) = New OleDb.OleDbParameter("@DepCode", OleDb.OleDbType.VarWChar)
            tmpParas(13) = New OleDb.OleDbParameter("@ReceiveCode", OleDb.OleDbType.VarWChar)
            tmpParas(14) = New OleDb.OleDbParameter("@PayCode", OleDb.OleDbType.VarWChar)
            tmpParas(15) = New OleDb.OleDbParameter("@GainCode", OleDb.OleDbType.VarWChar)
            tmpParas(16) = New OleDb.OleDbParameter("@DevCode", OleDb.OleDbType.VarWChar)
            tmpParas(17) = New OleDb.OleDbParameter("@StockCode", OleDb.OleDbType.VarWChar)
            tmpParas(18) = New OleDb.OleDbParameter("@IncAndDecCode", OleDb.OleDbType.VarWChar)
            tmpParas(19) = New OleDb.OleDbParameter("@IfPrintQuantity", OleDb.OleDbType.Boolean)
            tmpParas(20) = New OleDb.OleDbParameter("@IfPrintForeignMoney", OleDb.OleDbType.Boolean)
            tmpParas(21) = New OleDb.OleDbParameter("@IfPrintBankInfo", OleDb.OleDbType.Boolean)
            tmpParas(22) = New OleDb.OleDbParameter("@IfPrintNegative", OleDb.OleDbType.Boolean)
            tmpParas(23) = New OleDb.OleDbParameter("@IfPrintManager", OleDb.OleDbType.Boolean)
            tmpParas(24) = New OleDb.OleDbParameter("@IfPrintPoster", OleDb.OleDbType.Boolean)
            tmpParas(25) = New OleDb.OleDbParameter("@IfPrintChecker", OleDb.OleDbType.Boolean)
            tmpParas(26) = New OleDb.OleDbParameter("@IfPrintCasher", OleDb.OleDbType.Boolean)
            tmpParas(27) = New OleDb.OleDbParameter("@IfPrintMaker", OleDb.OleDbType.Boolean)
            tmpParas(28) = New OleDb.OleDbParameter("@IfPrintPerson", OleDb.OleDbType.Boolean)
            tmpParas(29) = New OleDb.OleDbParameter("@IfPrintDate", OleDb.OleDbType.Boolean)
            tmpParas(30) = New OleDb.OleDbParameter("@IfSelfPostVoucher", OleDb.OleDbType.Boolean)
            tmpParas(31) = New OleDb.OleDbParameter("@IfSelfCheckVoucher", OleDb.OleDbType.Boolean)
            tmpParas(32) = New OleDb.OleDbParameter("@LedgerAbSetup", OleDb.OleDbType.Integer)
            tmpParas(33) = New OleDb.OleDbParameter("@LedgerId", OleDb.OleDbType.Integer)
            tmpParas(34) = New OleDb.OleDbParameter("@RelativeLedgerId", OleDb.OleDbType.Integer)
            tmpParas(35) = New OleDb.OleDbParameter("@LedgerOneLevelLength", OleDb.OleDbType.Integer)

            tmpParas(0).Value = tmpCls.CompanyName
            tmpParas(1).Value = tmpCls.IndustryTypeId
            tmpParas(2).Value = tmpCls.IndustryType
            tmpParas(3).Value = tmpCls.LedgerIfOpened
            tmpParas(4).Value = tmpCls.LedgerOpenedDate  '"#" & tmpCls.LedgerOpenedDate.ToShortDateString() & "#"
            tmpParas(5).Value = tmpCls.LedgerWorkYear
            tmpParas(6).Value = tmpCls.LedgerOpenWorkYear
            tmpParas(7).Value = tmpCls.LedgerSubAcctLength
            tmpParas(8).Value = tmpCls.LedgerOwnerCurrency
            tmpParas(9).Value = tmpCls.CashCode
            tmpParas(10).Value = tmpCls.BankCode
            tmpParas(11).Value = tmpCls.AssetsCode
            tmpParas(12).Value = tmpCls.DepCode
            tmpParas(13).Value = tmpCls.ReceiveCode
            tmpParas(14).Value = tmpCls.PayCode
            tmpParas(15).Value = tmpCls.GainCode
            tmpParas(16).Value = IIf(String.IsNullOrEmpty(tmpCls.DevCode), "", tmpCls.DevCode)
            tmpParas(17).Value = tmpCls.StockCode
            tmpParas(18).Value = tmpCls.IncAndDecCode
            tmpParas(19).Value = tmpCls.IfPrintQuantity
            tmpParas(20).Value = tmpCls.IfPrintForeignMoney
            tmpParas(21).Value = tmpCls.IfPrintBankInfo
            tmpParas(22).Value = tmpCls.IfPrintNegative
            tmpParas(23).Value = tmpCls.IfPrintManager
            tmpParas(24).Value = tmpCls.IfPrintPoster
            tmpParas(25).Value = tmpCls.IfPrintChecker
            tmpParas(26).Value = tmpCls.IfPrintCasher
            tmpParas(27).Value = tmpCls.IfPrintMaker
            tmpParas(28).Value = tmpCls.IfPrintPerson
            tmpParas(29).Value = tmpCls.IfPrintDate
            tmpParas(30).Value = tmpCls.IfSelfPostVoucher
            tmpParas(31).Value = tmpCls.IfSelfCheckVoucher
            tmpParas(32).Value = tmpCls.LedgerAbSetup '正常
            tmpParas(33).Value = tmpCls.LedgerId
            tmpParas(34).Value = tmpCls.RelativeLedgerId
            tmpParas(35).Value = tmpCls.OneAcctLevelLength

            'tmpParas(0).Value = tmpCls.LedgerSettingId
            'tmpParas(0).Value = ConvertStringDbNull(tmpCls.CompanyName)
            'tmpParas(1).Value = tmpCls.IndustryTypeId
            'tmpParas(2).Value = ConvertStringDbNull(tmpCls.IndustryType)
            'tmpParas(3).Value = tmpCls.LedgerIfOpened
            'tmpParas(4).Value = tmpCls.LedgerOpenedDate
            'tmpParas(5).Value = ConvertStringDbNull(tmpCls.LedgerWorkYear)
            'tmpParas(6).Value = ConvertStringDbNull(tmpCls.LedgerOpenWorkYear)
            'tmpParas(7).Value = tmpCls.LedgerSubAcctLength
            'tmpParas(8).Value = ConvertStringDbNull(tmpCls.LedgerOwnerCurrency)
            'tmpParas(9).Value = ConvertStringDbNull(tmpCls.CashCode)
            'tmpParas(10).Value = ConvertStringDbNull(tmpCls.BankCode)
            'tmpParas(11).Value = ConvertStringDbNull(tmpCls.AssetsCode)
            'tmpParas(12).Value = ConvertStringDbNull(tmpCls.DepCode)
            'tmpParas(13).Value = ConvertStringDbNull(tmpCls.ReceiveCode)
            'tmpParas(14).Value = ConvertStringDbNull(tmpCls.PayCode)
            'tmpParas(15).Value = ConvertStringDbNull(tmpCls.GainCode)
            'tmpParas(16).Value = ConvertStringDbNull(tmpCls.DevCode)
            'tmpParas(17).Value = ConvertStringDbNull(tmpCls.StockCode)
            'tmpParas(18).Value = ConvertStringDbNull(tmpCls.IncAndDecCode)
            'tmpParas(19).Value = tmpCls.IfPrintQuantity
            'tmpParas(20).Value = tmpCls.IfPrintForeignMoney
            'tmpParas(21).Value = tmpCls.IfPrintBankInfo
            'tmpParas(22).Value = tmpCls.IfPrintNegative
            'tmpParas(23).Value = tmpCls.IfPrintManager
            'tmpParas(24).Value = tmpCls.IfPrintPoster
            'tmpParas(25).Value = tmpCls.IfPrintChecker
            'tmpParas(26).Value = tmpCls.IfPrintCasher
            'tmpParas(27).Value = tmpCls.IfPrintMaker
            'tmpParas(28).Value = tmpCls.IfPrintPerson
            'tmpParas(29).Value = tmpCls.IfPrintDate
            'tmpParas(30).Value = tmpCls.IfSelfPostVoucher
            'tmpParas(31).Value = tmpCls.IfSelfCheckVoucher
            'tmpParas(32).Value = tmpCls.LedgerAbSetup
            'tmpParas(33).Value = tmpCls.LedgerId
            'tmpParas(34).Value = tmpCls.RelativeLedgerId
            'tmpParas(35).Value = tmpCls.OneAcctLevelLength

            tmpReturn = tmpDbAccess.InsertData(tmpSql, tmpParas, True) 'UpdateRecord(tmpSql, tmpParas)

            '关闭数据库
            tmpDbAccess.DbClose()

            Return tmpReturn

        Catch ex As OleDb.OleDbException

            mErrorNumber = ex.ErrorCode
            mErrorMessage = ex.Message
            mErrorCreater = "clsAppDbAccess - UpdateTLedgerSetting"

            Return 0
        End Try
    End Function

    ''' <summary>
    ''' 更新用户账套参数
    ''' </summary>
    ''' <param name="tmpCls">ClsTLedgerSetting类对象</param>
    ''' <returns>非0成功，即影响行数</returns>
    Public Function UpdateTLedgerSetting(ByVal tmpCls As ClsTLedgerSetting) As Int16
        Try

            Dim tmpSql As String
            Dim tmpDbAccess = GetConnection() 'New ClsDbAccessMdb(mConnectionString)
            Dim tmpParas(36) As OleDb.OleDbParameter
            Dim tmpReturn As Integer

            '打开数据库
            tmpDbAccess.DbOpen()
            '构造查询语句
            tmpSql = "update [" & TABLE_NAME_T_LEDGER_SETTING & "] set [CompanyName]=@CompanyName,[IndustryTypeId]=@IndustryTypeId,"
            tmpSql &= "[IndustryType]=@IndustryType,[LedgerIfOpened]=@LedgerIfOpened,[LedgerOPendDate]=@LedgerOPendDate,"
            tmpSql &= "[LedgerWorkYear]=@LedgerWorkYear,[LedgerOpenedWorkYear]=@LedgerOpenedWorkYear,[LedgerSubAcctLength]=@LedgerSubAcctLength,"
            tmpSql &= "[LedgerOwnerCurrency]=@LedgerOwnerCurrency,[CashCode]=@CashCode,[BankCode]=@BankCode,[AssetsCode]=@AssetsCode,"
            tmpSql &= "[DepCode]=@DepCode,[ReceiveCode]=@ReceiveCode,[PayCode]=@PayCode,[GainCode]=@GainCode,[DevCode]=@DevCode,"
            tmpSql &= "[StockCode]=@StockCode,[IncAndDecCode]=@IncAndDecCode,[IfPrintQuantity]=@IfPrintQuantity,"
            tmpSql &= "[IfPrintForeignMoney]=@IfPrintForeignMoney,[IfPrintBankInfo]=@IfPrintBankInfo,[IfPrintNegative]=@IfPrintNegative,"
            tmpSql &= "[IfPrintManager]=@IfPrintManager,[IfPrintPoster]=@IfPrintPoster,[IfPrintChecker]=@IfPrintChecker,"
            tmpSql &= "[IfPrintCasher]=@IfPrintCasher,[IfPrintMaker]=@IfPrintMaker,[IfPrintPerson]=@IfPrintPerson,[IfPrintDate]=@IfPrintDate,"
            tmpSql &= "[IfSelfPostVoucher]=@IfSelfPostVoucher,[IfSelfCheckVoucher]=@IfSelfCheckVoucher,[LedgerAbSetup]=@LedgerAbSetup,"
            tmpSql &= "[LedgerId]=@LedgerId,[RelativeLedgerId]=@RelativeLedgerId,[LedgerOneLevelLength]=@LedgerOneLevelLength"
            tmpSql &= " where [LedgerSettingId]=@LedgerSettingId"

            '查询参数类型
            tmpParas(0) = New OleDb.OleDbParameter("@CompanyName", OleDb.OleDbType.VarWChar)
            tmpParas(1) = New OleDb.OleDbParameter("@IndustryTypeId", OleDb.OleDbType.Integer)
            tmpParas(2) = New OleDb.OleDbParameter("@IndustryType", OleDb.OleDbType.VarWChar)
            tmpParas(3) = New OleDb.OleDbParameter("@LedgerIfOpened", OleDb.OleDbType.Boolean)
            tmpParas(4) = New OleDb.OleDbParameter("@LedgerOpenedDate", OleDb.OleDbType.DBTimeStamp)
            tmpParas(5) = New OleDb.OleDbParameter("@LedgerWorkYear", OleDb.OleDbType.VarWChar)
            tmpParas(6) = New OleDb.OleDbParameter("@LedgerOpenWorkYear", OleDb.OleDbType.VarWChar)
            tmpParas(7) = New OleDb.OleDbParameter("@LedgerSubAcctLength", OleDb.OleDbType.Integer)
            tmpParas(8) = New OleDb.OleDbParameter("@LedgerOwnerCurrency", OleDb.OleDbType.VarWChar)
            tmpParas(9) = New OleDb.OleDbParameter("@CashCode", OleDb.OleDbType.VarWChar)
            tmpParas(10) = New OleDb.OleDbParameter("@BankCode", OleDb.OleDbType.VarWChar)
            tmpParas(11) = New OleDb.OleDbParameter("@AssetsCode", OleDb.OleDbType.VarWChar)
            tmpParas(12) = New OleDb.OleDbParameter("@DepCode", OleDb.OleDbType.VarWChar)
            tmpParas(13) = New OleDb.OleDbParameter("@ReceiveCode", OleDb.OleDbType.VarWChar)
            tmpParas(14) = New OleDb.OleDbParameter("@PayCode", OleDb.OleDbType.VarWChar)
            tmpParas(15) = New OleDb.OleDbParameter("@GainCode", OleDb.OleDbType.VarWChar)
            tmpParas(16) = New OleDb.OleDbParameter("@DevCode", OleDb.OleDbType.VarWChar)
            tmpParas(17) = New OleDb.OleDbParameter("@StockCode", OleDb.OleDbType.VarWChar)
            tmpParas(18) = New OleDb.OleDbParameter("@IncAndDecCode", OleDb.OleDbType.VarWChar)
            tmpParas(19) = New OleDb.OleDbParameter("@IfPrintQuantity", OleDb.OleDbType.Boolean)
            tmpParas(20) = New OleDb.OleDbParameter("@IfPrintForeignMoney", OleDb.OleDbType.Boolean)
            tmpParas(21) = New OleDb.OleDbParameter("@IfPrintBankInfo", OleDb.OleDbType.Boolean)
            tmpParas(22) = New OleDb.OleDbParameter("@IfPrintNegative", OleDb.OleDbType.Boolean)
            tmpParas(23) = New OleDb.OleDbParameter("@IfPrintManager", OleDb.OleDbType.Boolean)
            tmpParas(24) = New OleDb.OleDbParameter("@IfPrintPoster", OleDb.OleDbType.Boolean)
            tmpParas(25) = New OleDb.OleDbParameter("@IfPrintChecker", OleDb.OleDbType.Boolean)
            tmpParas(26) = New OleDb.OleDbParameter("@IfPrintCasher", OleDb.OleDbType.Boolean)
            tmpParas(27) = New OleDb.OleDbParameter("@IfPrintMaker", OleDb.OleDbType.Boolean)
            tmpParas(28) = New OleDb.OleDbParameter("@IfPrintPerson", OleDb.OleDbType.Boolean)
            tmpParas(29) = New OleDb.OleDbParameter("@IfPrintDate", OleDb.OleDbType.Boolean)
            tmpParas(30) = New OleDb.OleDbParameter("@IfSelfPostVoucher", OleDb.OleDbType.Boolean)
            tmpParas(31) = New OleDb.OleDbParameter("@IfSelfCheckVoucher", OleDb.OleDbType.Boolean)
            tmpParas(32) = New OleDb.OleDbParameter("@LedgerAbSetup", OleDb.OleDbType.Integer)
            tmpParas(33) = New OleDb.OleDbParameter("@LedgerId", OleDb.OleDbType.Integer)
            tmpParas(34) = New OleDb.OleDbParameter("@RelativeLedgerId", OleDb.OleDbType.Integer)
            tmpParas(35) = New OleDb.OleDbParameter("@LedgerOneLevelLength", OleDb.OleDbType.SmallInt)
            tmpParas(36) = New OleDb.OleDbParameter("@LedgerSettingId", OleDb.OleDbType.Integer)

            '查询参数赋值
            tmpParas(0).Value = tmpCls.CompanyName
            tmpParas(1).Value = tmpCls.IndustryTypeId
            tmpParas(2).Value = tmpCls.IndustryType
            tmpParas(3).Value = tmpCls.LedgerIfOpened
            tmpParas(4).Value = tmpCls.LedgerOpenedDate
            tmpParas(5).Value = tmpCls.LedgerWorkYear
            tmpParas(6).Value = tmpCls.LedgerOpenWorkYear
            tmpParas(7).Value = tmpCls.LedgerSubAcctLength
            tmpParas(8).Value = tmpCls.LedgerOwnerCurrency
            tmpParas(9).Value = tmpCls.CashCode
            tmpParas(10).Value = tmpCls.BankCode
            tmpParas(11).Value = tmpCls.AssetsCode
            tmpParas(12).Value = tmpCls.DepCode
            tmpParas(13).Value = tmpCls.ReceiveCode
            tmpParas(14).Value = tmpCls.PayCode
            tmpParas(15).Value = tmpCls.GainCode
            tmpParas(16).Value = tmpCls.DevCode
            tmpParas(17).Value = tmpCls.StockCode
            tmpParas(18).Value = tmpCls.IncAndDecCode
            tmpParas(19).Value = tmpCls.IfPrintQuantity
            tmpParas(20).Value = tmpCls.IfPrintForeignMoney
            tmpParas(21).Value = tmpCls.IfPrintBankInfo
            tmpParas(22).Value = tmpCls.IfPrintNegative
            tmpParas(23).Value = tmpCls.IfPrintManager
            tmpParas(24).Value = tmpCls.IfPrintPoster
            tmpParas(25).Value = tmpCls.IfPrintChecker
            tmpParas(26).Value = tmpCls.IfPrintCasher
            tmpParas(27).Value = tmpCls.IfPrintMaker
            tmpParas(28).Value = tmpCls.IfPrintPerson
            tmpParas(29).Value = tmpCls.IfPrintDate
            tmpParas(30).Value = tmpCls.IfSelfPostVoucher
            tmpParas(31).Value = tmpCls.IfSelfCheckVoucher
            tmpParas(32).Value = tmpCls.LedgerAbSetup
            tmpParas(33).Value = tmpCls.LedgerId
            tmpParas(34).Value = tmpCls.RelativeLedgerId
            tmpParas(35).Value = tmpCls.OneAcctLevelLength
            tmpParas(36).Value = tmpCls.LedgerSettingId

            tmpReturn = tmpDbAccess.UpdateRecord(tmpSql, tmpParas)

            '关闭数据库
            tmpDbAccess.DbClose()

            Return tmpReturn

        Catch ex As OleDb.OleDbException

            mErrorNumber = ex.ErrorCode
            mErrorMessage = ex.Message
            mErrorCreater = "clsAppDbAccess - UpdateTLedgerSetting"

            Return -1
        End Try

    End Function


    ''' <summary>
    ''' 查询指定账套是否已启用
    ''' </summary>
    ''' <param name="lId">指定账套的编号LedgerId</param>
    ''' <returns>T/F </returns>
    Public Function GetIfOpenByLedgerId(ByVal lId As Int32) As Boolean
        Try

            Dim tmpRet As Boolean
            Dim tmpSql As String
            Dim tmpDbAccess = GetConnection() 'New ClsDbAccessMdb(mConnectionString)

            '打开数据库
            tmpDbAccess.DbOpen()
            '构造查询语句
            tmpSql = "select [LedgerIfOpened] from [" & TABLE_NAME_T_LEDGER_SETTING & "] where [LedgerSettingId] = @LedgerSettingId"
            Dim tmpParas(0) As OleDb.OleDbParameter
            tmpParas(0) = New OleDb.OleDbParameter("@LedgerSeetingId", OleDb.OleDbType.Integer)
            tmpParas(0).Value = lId

            '将一行数据转为类对象
            tmpRet = CType(tmpDbAccess.ExecuteSqlReturnUniqueField(tmpSql, tmpParas), Boolean)
            '关闭数据库
            tmpDbAccess.DbClose()

            Return tmpRet

        Catch ex As OleDb.OleDbException

            mErrorNumber = ex.ErrorCode
            mErrorMessage = ex.Message
            mErrorCreater = "ClsTLedgerSettingDbAccess - GetLedgerSetting"

            Return False
        End Try
    End Function

    ''' <summary>
    ''' 返回当前用户账套的设置信息
    ''' </summary>
    ''' <returns></returns>
    Public Function GetLedgerSetting() As ClsTLedgerSetting
        Try

            Dim tmpCls As ClsTLedgerSetting
            Dim tmpSql As String
            Dim tmpDbAccess = GetConnection() 'New ClsDbAccessMdb(mConnectionString)

            '打开数据库
            tmpDbAccess.DbOpen()
            '构造查询语句
            tmpSql = "select * from [" & TABLE_NAME_T_LEDGER_SETTING & "] "
            '将一行数据转为类对象
            tmpCls = CType(ConvertRecordToClass(tmpDbAccess.ExecuteSqlReturnDataSet(tmpSql)), ClsTLedgerSetting)
            '关闭数据库
            tmpDbAccess.DbClose()

            Return tmpCls

        Catch ex As OleDb.OleDbException

            mErrorNumber = ex.ErrorCode
            mErrorMessage = ex.Message
            mErrorCreater = "ClsTLedgerSettingDbAccess - GetLedgerSetting"

            Return Nothing
        End Try
    End Function

    ''' <summary>
    ''' 将表中记录转换为类对象,只返回第一行记录
    ''' </summary>
    ''' <param name="tmpTableReader">读取的记录集</param>
    ''' <returns>ClsTLedgerSetting类对象</returns>
    Public Overrides Function ConvertRecordToClass(ByVal tmpTableReader As OleDb.OleDbDataReader) As Object
        If tmpTableReader Is Nothing Then
            Return Nothing
        End If

        Dim tmpCls As ClsTLedgerSetting = Nothing

        Try

            If tmpTableReader.Read() Then
                tmpCls = New ClsTLedgerSetting()

                With tmpCls

                    .LedgerSettingId = tmpTableReader.GetInt32(0)
                    .CompanyName = tmpTableReader.GetString(1)
                    .IndustryTypeId = tmpTableReader.GetInt32(2)
                    .IndustryType = tmpTableReader.GetString(3)
                    .LedgerIfOpened = tmpTableReader.GetBoolean(4)
                    .LedgerOpenedDate = ConvertDbNullDateTime(tmpTableReader(5))
                    .LedgerWorkYear = ConvertDbNullString(tmpTableReader(6)) 'tmpTableReader.GetString(6)
                    .LedgerOpenWorkYear = ConvertDbNullString(tmpTableReader(7)) 'tmpTableReader.GetString(7) '6位: 202101
                    .LedgerSubAcctLength = tmpTableReader.GetInt16(8) '默认次级科目长度为 3
                    .LedgerOwnerCurrency = ConvertDbNullString(tmpTableReader(9)) 'tmpTableReader.GetString(9) '本位币
                    .CashCode = ConvertDbNullString(tmpTableReader(10)) 'tmpTableReader.GetString(10) '现金科目
                    .BankCode = ConvertDbNullString(tmpTableReader(11)) 'tmpTableReader.GetString(11) '银行科目
                    .AssetsCode = ConvertDbNullString(tmpTableReader(12)) 'tmpTableReader.GetString(12) '固定资产科目
                    .DepCode = ConvertDbNullString(tmpTableReader(13)) 'tmpTableReader.GetString(13) '累计折旧科目
                    .ReceiveCode = ConvertDbNullString(tmpTableReader(14)) 'tmpTableReader.GetString(14) '应收账款科目
                    .PayCode = ConvertDbNullString(tmpTableReader(15)) 'tmpTableReader.GetString(15) '应付账款科目
                    .GainCode = ConvertDbNullString(tmpTableReader(16)) ' tmpTableReader.GetString(16) '本年利润科目
                    .DevCode = ConvertDbNullString(tmpTableReader(17)) ' tmpTableReader.GetString(17) '损益汇兑科目
                    .StockCode = ConvertDbNullString(tmpTableReader(18)) ' tmpTableReader.GetString(18) '存货科目
                    .IncAndDecCode = ConvertDbNullString(tmpTableReader(19)) ' tmpTableReader.GetString(19) '损益科目
                    .IfPrintQuantity = tmpTableReader.GetBoolean(20)
                    .IfPrintForeignMoney = tmpTableReader.GetBoolean(21)
                    .IfPrintBankInfo = tmpTableReader.GetBoolean(22)
                    .IfPrintNegative = tmpTableReader.GetBoolean(23)
                    .IfPrintManager = tmpTableReader.GetBoolean(24)
                    .IfPrintPoster = tmpTableReader.GetBoolean(25)
                    .IfPrintChecker = tmpTableReader.GetBoolean(26)
                    .IfPrintCasher = tmpTableReader.GetBoolean(27)
                    .IfPrintMaker = tmpTableReader.GetBoolean(28)
                    .IfPrintPerson = tmpTableReader.GetBoolean(29)
                    .IfPrintDate = tmpTableReader.GetBoolean(30)
                    .IfSelfPostVoucher = tmpTableReader.GetBoolean(31) '是否允许同一个人过账
                    .IfSelfCheckVoucher = tmpTableReader.GetBoolean(32) '是否允许同一个人审核凭证
                    .LedgerAbSetup = ConvertDbNullInteger(tmpTableReader(33)) 'tmpTableReader.GetInt16(33) '是否AB账，0- 不分，1- A 2-B
                    .LedgerId = ConvertDbNullInteger(tmpTableReader(34)) 'tmpTableReader.GetInt32(34) '当前账套在sys.mdb表S_Ledger中的账套编号
                    .RelativeLedgerId = ConvertDbNullInteger(tmpTableReader(35)) 'tmpTableReader.GetInt32(35) '如果是AB账，则相关账套在sys.mdb S_Ledger表中的账套编号
                    .OneAcctLevelLength = ConvertDbNullInteger(tmpTableReader(36))
                End With
            End If

        Catch ex As OleDb.OleDbException

            mErrorNumber = ex.ErrorCode
            mErrorMessage = ex.Message
            mErrorCreater = "ClsTLedgerSettingDbAccess - ConvertRecordToClass"

            Return Nothing
        End Try

        Return tmpCls

    End Function
End Class
